﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:UI.Resources.Converters"
             x:Class="UI.Resources.Controls.SubstitutableDataGrid"  
             mc:Ignorable="d" 
             Name="This"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <converters:InverseNullToVisibilityConverter x:Key="InverseNullToVisibilityConverter"/>
        <converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
		<Style TargetType="{x:Type DataGrid}" x:Key="DataGridStyle">
			<Setter Property="Background" Value="#E5F1E4"/>
			<Setter Property="HeadersVisibility" Value="Column"/>
			<Setter Property="AlternationCount" Value="2"/>
			<Setter Property="SelectionMode" Value="Extended"/>
			<Setter Property="ClipboardCopyMode" Value="IncludeHeader"/>
			<Setter Property="HorizontalGridLinesBrush" Value="#C6D7C5"/>
			<Setter Property="VerticalGridLinesBrush" Value="#C6D7C5"/>
			<Setter Property="SelectionUnit" Value="FullRow"/>
		</Style>
    </UserControl.Resources>

    <Grid>
        <UserControl Content="{Binding ElementName=This, Path=SubstitutionTemplate}" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}"/>
		<DataGrid Name="CasesDataGrid" Visibility="{Binding Converter={StaticResource InverseNullToVisibilityConverter}, Mode=OneWay}" ItemsSource="{Binding ElementName=This, Path=Research.Cases}" AutoGeneratedColumns="DataGridAutoGeneratedColumns" Style="{StaticResource ResourceKey=DataGridStyle}" CellEditEnding="DataGrid_OnCellEditEnding" InitializingNewItem="DataGridInitializingNewItem"/>
    </Grid>
</UserControl>